package cn.iocoder.yudao.module.contract.dal.mysql.basicData;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicBrokerageDO;
import cn.iocoder.yudao.module.contract.dal.dataobject.basicData.BasicPackingDO;
import cn.iocoder.yudao.module.contract.utils.StringUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.contract.controller.admin.basicData.vo.*;

/**
 * 包装方式 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface BasicPackingMapper extends BaseMapperX<BasicPackingDO> {

    default PageResult<BasicPackingDO> selectPage(BasicPackingPageReqVO reqVO) {
        return selectPage(reqVO, new MPJLambdaWrapperX<BasicPackingDO>()
                .likeIfPresent(BasicPackingDO::getName, reqVO.getName())
                .eqIfPresent(BasicPackingDO::getCode, reqVO.getCode())
                .eqIfPresent(BasicPackingDO::getValue, reqVO.getValue())
                .betweenIfPresent(BasicPackingDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ObjectUtils.isEmpty(reqVO.getOrder()), BasicPackingDO::getCreateTime)
                .orderBy(ObjectUtils.isNotEmpty(reqVO.getOrder()),"ascending".equals(reqVO.getOrder()), StringUtils.toUnderScoreCase(reqVO.getProp())));
    }

}